Convert uploaded video files to mp4 using PHP [closed]

Posted by Subin on Programmers See other posts from Programmers or by Subin
Published on 2012-09-30T15:06:32Z Indexed on 2012/10/01 15:52 UTC
Read the original article Hit count: 238

Filed under:

I created a PHP video uploading script. I need to convert these files to mp4 for HTML5 VIDEO PLAYER using PHP while uploading . How can I do that ? Here is the PHP code.

<?php 
if(isset($_POST['submit'])){
$user=$_COOKIE['VisitorName'];
include('config.php');
session_start();
$session_id='1'; //$session id
$path = "/home/simsu/subins/videos/data/videos/";

    $valid_formats = array("wmv", "ogv", "mp4", "3gp", "ogg");
    if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
        {
            $name = $_FILES['uploadedfile']['name'];
            $size = $_FILES['uploadedfile']['size'];

            if(strlen($name))
                {
                    list($txt, $ext) = explode(".", $name);
                    if(in_array($ext,$valid_formats))
                    {
                    if($size<(100024*100024))
                        {
                            $actual_image_name = $path.time().".mp4";
                            $tmp = $_FILES['uploadedfile']['tmp_name'];
$upurl="http://vtube.subins.com/files/video?vid=".time();
$title=$_POST['vn'];
        mysql_query("INSERT INTO videos(title,user,url,vid,ext) VALUES ('$title', '$user','$upurl',NOW(),'$ext')");

echo '<br><h1>'.$_FILES['uploadedfile']['name'] . " uploaded.</h1>";

                        }
                        else
                        echo "<br><h1>Video file size max 100 MB";                  
                        }
                        else
                        echo "<br><h1>Invalid file format..";   
                }

            else
                echo "<br><h1>Please select a video..!";

            exit;
        }
}
?>

© Programmers or respective owner

Related posts about php